﻿/* AgileFx Version 1.0
 * An open-source framework for rapid development of applications and services using Microsoft.net
 * Developed by: AgileHead
 * Website: www.agilefx.org
 * This component is licensed under the terms of the Apache 2.0 License.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace AgileFx.EF
{
    public class EFObjectContextWrapper : IObjectContext
    {
        ObjectContext objContext;
        public EFObjectContextWrapper(ObjectContext objContext)
        {
            this.objContext = objContext;
        }

        public ObjectQuery<T> CreateQuery<T>(string queryString, params ObjectParameter[] parameters)
        {
            return objContext.CreateQuery<T>(queryString, parameters);
        }

        public void DeleteObject(object obj)
        {
            objContext.DeleteObject(obj);
        }

        public void SaveChanges()
        {
            objContext.SaveChanges();            
        }

        public void AddObject(string entitySetName, object entity)
        {
            objContext.AddObject(entitySetName, entity);
        } 
    }
}
